import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
// import Home from '../views/Home.vue'
// import Login from '@/layouts/admin/Login.vue'
import BlankRouterView from '@/layouts/BlankRouterView.vue'
import AdminView from '@/layouts/cms/AdminView.vue'

Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
  {
    path: '/cms',
    component: BlankRouterView,
    children: [
      {
        name: 'login',
        path: 'login',
        component: () => import('@/views/cms/Login.vue'),
        meta: {
          requireAuth: false,
          title: 'CMS 登录'
        }
      },
      {
        path: '',
        component: AdminView,
        children: [
          {
            name: 'workbench',
            path: '',
            component: () => import('@/views/cms/Workbench.vue'),
            meta: {
              requireAuth: true,
              title: '我的工作台'
            }
          }
        ]
      },
      // 个人
      {
        name: 'personal',
        path: 'personal',
        component: AdminView,
        children: [
          {
            name: 'resume',
            path: 'resume',
            component: () => import('@/views/cms/personal/resume/Index.vue'),
            meta: {
              requireAuth: true,
              title: '简历库'
            }
          },
          {
            name: 'personalUser',
            path: 'user',
            component: () => import('@/views/cms/personal/personal-user/Index.vue'),
            meta: {
              requireAuth: true,
              title: '个人注册用户'
            }
          }
        ]
      },

      // 企业
      {
        name: 'company',
        path: 'company',
        component: AdminView,
        children: [
          {
            name: 'companyUser',
            path: 'user',
            component: () => import('@/views/cms/company/company-user/Index.vue'),
            meta: {
              requireAuth: true,
              title: '企业注册用户'
            }
          },
          {
            name: 'companyBasic',
            path: 'basic',
            component: () => import('@/views/cms/company/company-basic/Index.vue'),
            meta: {
              requireAuth: true,
              title: '企业基本资料'
            }
          },
          {
            name: 'companyJob',
            path: 'job',
            component: () => import('@/views/cms/company/company-job/Index.vue'),
            meta: {
              requireAuth: true,
              title: '企业招聘'
            }
          }
        ]
      },
      
      // 管理员
      {
        name: 'admin',
        path: 'admin',
        component: AdminView,
        children: [
          {
            name: 'adminUser',
            path: 'admin-user',
            component: () => import('@/views/cms/admin/admin-user/Index.vue'),
            meta: {
              requireAuth: true,
              title: '管理员管理'
            }
          },
          {
            name: 'permission',
            path: 'permission',
            component: () => import('@/views/cms/admin/permission/Index.vue'),
            meta: {
              requireAuth: true,
              title: '权限管理'
            }
          },
          {
            name: 'role',
            path: 'role',
            component: () => import('@/views/cms/admin/role/Index.vue'),
            meta: {
              requireAuth: true,
              title: '角色管理'
            }
          },
          {
            name: 'log',
            path: 'log',
            component: () => import('@/views/cms/admin/role/Index.vue'),
            meta: {
              requireAuth: true,
              title: '操作日志'
            }
          }
        ]
      },
      {
        // name: '找不到页面',
        path: '*',
        component: AdminView,
        children: [
          {
            name: 'notFount',
            path: '',
            component: () => import('@/views/error/notFount.vue'),
            meta: {
              requireAuth: false,
              title: '找不到页面'
            }
          }
        ]
      }
    ]
  },
  {
    name: 'CRM',
    path: '/crm',
    component: BlankRouterView,
    children: [
      {
        name: 'crmLogin',
        path: 'login',
        component: () => import('@/views/crm/Login.vue'),
        meta: {
          requireAuth: false,
          title: 'CRM 登录'
        }
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
